home *** CD-ROM | disk | FTP | other *** search
/ Geek Games #12 / GEGA012.iso / Jogos de Azar / 1721-apuesten.swf / scripts / C_AutoButtonCLASS.as next >
Text File  |  2006-01-17  |  2KB  |  104 lines

  1. _global.C_AutoButtonCLASS = function()
  2. {
  3.    this.autoOn = false;
  4. };
  5. C_AutoButtonCLASS.prototype = new MovieClip();
  6. C_AutoButtonCLASS.prototype.onLoad = function()
  7. {
  8.    this.a_btn.addAlt(function()
  9.    {
  10.       if(this._parent.autoOn)
  11.       {
  12.          this.showAlt("Turn auto start game OFF");
  13.       }
  14.       else
  15.       {
  16.          this.showAlt("Turn auto start game ON");
  17.       }
  18.    }
  19.    ,function()
  20.    {
  21.       this.hideAlt();
  22.    }
  23.    );
  24.    this.a_btn.onPress = function()
  25.    {
  26.       this.hideAlt();
  27.       this._parent.onButtonPress();
  28.    };
  29.    this.a_btn.useHandCursor = true;
  30.    this.a_btn._brightness = -50;
  31.    this.label_mc._brightness = -50;
  32.    this.stopTimer();
  33. };
  34. C_AutoButtonCLASS.prototype.lock = function()
  35. {
  36.    this.onRelease = function()
  37.    {
  38.    };
  39.    this.useHandCursor = false;
  40.    if(this.autoOn)
  41.    {
  42.       this.stopTimer();
  43.    }
  44. };
  45. C_AutoButtonCLASS.prototype.unlock = function()
  46. {
  47.    delete this.onRelease;
  48.    delete this.useHandCursor;
  49.    if(this.autoOn)
  50.    {
  51.       this.startTimer();
  52.    }
  53. };
  54. C_AutoButtonCLASS.prototype.onButtonPress = function()
  55. {
  56.    if(this.autoOn)
  57.    {
  58.       this.autoOn = false;
  59.       this.a_btn._brightness = -50;
  60.       this.label_mc._brightness = -50;
  61.       this.stopTimer();
  62.    }
  63.    else
  64.    {
  65.       this.autoOn = true;
  66.       this.a_btn._brightness = 0;
  67.       this.label_mc._brightness = 0;
  68.       this.startTimer();
  69.    }
  70. };
  71. C_AutoButtonCLASS.prototype.stopTimer = function()
  72. {
  73.    this.timer_mc._visible = 0;
  74.    clearInterval(this._interval);
  75. };
  76. C_AutoButtonCLASS.prototype.startTimer = function()
  77. {
  78.    this.timer = 1;
  79.    this._interval = setInterval(this,"onTimer",1000);
  80.    this.timer_mc.gotoAndStop(1);
  81.    this.timer_mc._visible = 1;
  82. };
  83. C_AutoButtonCLASS.prototype.onTimer = function()
  84. {
  85.    this.timer = this.timer + 1;
  86.    if(this.timer > 16)
  87.    {
  88.       this.timer = 1;
  89.       this.startGame();
  90.    }
  91.    this.timer_mc.gotoAndStop(this.timer);
  92. };
  93. C_AutoButtonCLASS.prototype.startGame = function()
  94. {
  95.    var c = this.client;
  96.    c.client[c.handler]();
  97. };
  98. C_AutoButtonCLASS.prototype.setChangeHandler = function(handler, client)
  99. {
  100.    this.client = {client:client,handler:handler};
  101. };
  102. ASSetPropFlags(_global,"C_AutoButtonCLASS",131);
  103. Object.registerClass("C_AutoButtonCLASS",C_AutoButtonCLASS);
  104.